﻿using System;
using System.Windows.Input;

namespace TestBat.ViewModels.Base.Commands
{
    class JoinedCommand : ICommand
    {
        public JoinedCommand(ICommand c1, ICommand c2)
        {
            this.c1 = c1;
            this.c2 = c2;

            CanExecuteChanged = new EventHandler((a,b) => {}); // to supress warning
            CanExecuteChanged = null;
        }

        public bool CanExecute(object parameter)
        {
            return c1.CanExecute(parameter) && c2.CanExecute(parameter);
        }

        public event EventHandler CanExecuteChanged;

        public void Execute(object parameter)
        {
            c1.Execute(parameter);
            c2.Execute(parameter);
        }

        private readonly ICommand c1;
        private readonly ICommand c2;
    }
}
